02-20-2024
Insomnia, Snoring, and Decision Tree
A fun journey on how I dealt with insomnia for a period in my life :P.
#Reflections
Take a magnifying glass to the world. What kinds of things are you (possibly subconsciously) paying close attention to that many others aren't? Are there recurring patterns in the kinds of things you're noticing?
As E. Joseph Cossman once said, 'The best bridge between despair and hope is a good night's sleep." In a personal twist, I'd say, 'The worst bridge between school and life is a bad night's sleep, or insomnia." Insomnia – a word that typically feels disconnected from the energetic world of teenagers – has been my constant companion since the day I stepped into boarding school.
One night, as I was staring at the ceiling and wondering about life’s big questions as usual, I came across the question, “Why can’t I go to sleep?” To answer this, I lay flat and closed my eyes, trying not to think about anything. However, the more I tried to keep my mind blank, the more tension and thoughts emerged. I realized I must focus on one specific thing to fall asleep. But what should I focus on? Counting sheep? Then, an idea popped into my mind: my two dormmates' snoring sounds.
The first thing I found is that they have identical snoring sounds, which are hard to distinguish. The primary difference was in their patterns, and as I tried to discern each one's pattern, I fell asleep. Thinking about one tiny thing, the snoring sound in my case, does help to fall asleep! Therefore, during the nights later that week, I found myself paying close attention to the patterns of my dormmates’ snoring sounds, and I became much more energetic the next day.
But simply focusing on the patterns of their snoring sounds was unfulfilling to me; I'm the type of person who always wants to build connections from observations. Soon, I know what’s the next thing to do - I’ll try to remember the frequency of their snorings, each of them’s, and compare it with my breathing pace to categorize them into “fast”, “equivalent”, and “slow”. Then, I’ll recall my memories the next day and write both of their frequencies down on a table from my Notion. Simultaneously, I would note four other categorical variables for each of my dormmates from the previous day: sports (Y/N), snacks before bed (Y/N), air conditioner temperature (low: <20/medium: 20-24/high: >24), and amount of homework (many/little). Thus, the table resembled a dataset, with the four variables as independent and snoring frequency as the dependent variable. However, it's important to note that there could be (and likely were) confounding variables.
By then, I was certain about my goal: to record the table's data daily and identify any correlations between the independent and dependent variables. There are already some clear recurring patterns that I found, such as one of my dormmate tend to snore slow if he did sports that day or ate snacks before bed. However, there are other patterns that are harder to discover. Luckily, I was learning about decision tree algorithms in Andrew Ng’s course that time. And so after a month of recording data, I decided to train a decision tree algorithm with the data to predict snoring frequencies of my two dormmates. The training proceeded well, as I employed the XGBoost algorithm to accommodate the limited data. With the trained model in hand, I ask my dormmates about those four variables each night before sleep, “did you kick football today?”. Then, I gave those variables to the model and it will predict if he will snore fast, equivalent, or slow tonight. I will compare the predicted result with the actual one that I observed the next morning, and guess what, the model achieved a 70% accuracy after ten days of comparison, which is definitely better than 33.33% accuracy if you guess the result!
In the end, my struggle with not being able to sleep turned into a cool project. By paying attention to how my dormmates snore, I figured out a way to fall asleep faster. It taught me to be creative in finding solutions and to use what I learn in real life. Admittedly, this journey had its flaws, notably the somewhat arbitrary selection of the four independent variables and their direct leap to conclusions, which might not stand up to rigorous scientific scrutiny. Now, going to bed isn't scary anymore. I learned to deal with it, enjoy it, and make the best of it.